<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2019/12/2-16:25
// +----------------------------------------------------------------------
// | Description:  
// +---------------------------------------------------------------------- 
*-->
<!DOCTYPE html>
<html lang="en" class="page-fill">
<head>
    <meta charset="UTF-8">
    <title>{:GetSysConfig('home_title')}后台登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="__ADMIN__/css/oksub.css"/>
</head>
<body class="page-fill">
<div class="page-fill" id="login">
    <form class="layui-form" method="post">
        <div class="login_face"><img src="__ADMIN__/images/jrk.jpg"></div>
        <div class="layui-form-item input-item">
            <label for="username">用户名</label>
            <input type="text" lay-verify="required" name="username" value="{$user.username}" placeholder="" autocomplete="off" id="username" class="layui-input">
        </div>
        <div class="layui-form-item input-item">
            <label for="password">密码</label>
            <input type="password" lay-verify="required|password" name="password" value="{$user.pass}" placeholder="" autocomplete="off" id="password" class="layui-input">
        </div>
        {:token()}
        <div class="layui-form-item input-item captcha-box">
            <label for="captcha">验证码</label>
            <input type="text" lay-verify="required|captcha" name="captcha" placeholder="" autocomplete="off" id="captcha" maxlength="4" class="layui-input">
            <div class="img ok-none-select" id="captchaImg"></div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-block" lay-filter="login" lay-submit="">登录</button>
        </div>
        <div class="login-link">
            <input type="checkbox" name="remember" lay-skin="primary" value="1" title="记住用户名密码" checked="">
        </div>

    </form>
</div>


<!--js逻辑-->
<script src="__PLUGS__/layui/layui.js"></script>

<script>
    layui.use(['form', "okGVerify", "okUtils",'jquery','util'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var okGVerify = layui.okGVerify;
        var okUtils = layui.okUtils;
        var util = layui.util;

        $(document).ready(function(){
            var srcWidth = okUtils.getBodyWidth();
            /*var notice = sessionStorage.getItem("pass");
            && notice != "true"*/
            if(srcWidth>800  ){
                layer.open({
                    type: 0
                    ,area: '250px'
                    ,shade:0
                    ,anim: 2
                    ,offset: "t"
                    ,content: '欢迎进QQ群：<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=7909af8d5f052f8f4d813497cdb3ce0f056f0048df22be9fce8393c146b70a67"><img border="0" src="//pub.idqqimg.com/wpa/images/group.png" alt="JrkAdmin" title="JrkAdmin"></a> 交流！'
                    ,title:'JRKAdmin'
                    ,time:15000
                    ,id:'tplay_msg'
                    ,move: false
                    ,btnAlign: 'c'
                    ,btn: '朕知道了'
                    ,yes: function(index, layero){
                       layer.close(index);
                    }
                });
            }

        });


        /**
         * 初始化验证码
         */
        var verifyCode = new okGVerify("#captchaImg");

        /**
         * 数据校验
         */
        form.verify({
            password: [/^[\S]{6,12}$/, "密码必须6到12位，且不能出现空格"],
            captcha: function (val) {
                if (verifyCode.validate(val) != "true") {
                    return verifyCode.validate(val)
                }
            }
        });

        /**
         * 提交数据
         */
        form.on('submit(login)', function (data) {
            var load=layer.load(2);
            $.ajax({
                url:"{:url('login/login_check')}",
                dataType:"json",
                type:'post',
                //data:$("#form").serialize(),
                data:data.field,
                success:function(data){
                    if(data.code==1)
                    {
                        layer.msg(data.msg, {icon: 1, time: 1500, anim: 4,shade:0.5}, function () {
                            layer.close(load);
                            window.location.href="{:url('admin/index/index')}";
                        });
                    }
                    else
                    {
                        layer.msg(data.msg, {icon: 5, time: 1000, anim: 4,shade:0.5}, function () {
                            layer.close(load);
                        });
                    }
                },
                error:function () {
                    layer.msg("网络错误", {icon: 5, time: 1000, anim: 4,shade:0.5}, function () {
                        layer.close(load);
                    });
                }
            });

            return false;
        });

        /**
         * 表单input组件单击时
         */
        $("#login .input-item .layui-input").click(function (e) {
            e.stopPropagation();
            $(this).addClass("layui-input-focus").find(".layui-input").focus();
        });

        /**
         * 表单input组件获取焦点时
         */
        $("#login .layui-form-item .layui-input").focus(function () {
            $(this).parent().addClass("layui-input-focus");
        });

        /**
         * 表单input组件失去焦点时
         */
        $("#login .layui-form-item .layui-input").blur(function () {
            $(this).parent().removeClass("layui-input-focus");
            if ($(this).val() != "") {
                $(this).parent().addClass("layui-input-active");
            } else {
                $(this).parent().removeClass("layui-input-active");
            }
        })

    });
</script>
</body>
</html>
